package com.atguigu.spzx.cloud.order.config;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration //来自spring框架
//@SpringBootConfiguration //来自springboot框架，代替@Configuration

//@LoadBalancerClients(value = {
//        @LoadBalancerClient(name = "spzx-cloud-user" , configuration = CustomLoadBalancerConfiguration.class)      // 将负载均衡算法应用到指定的服务提供方中
//})
public class RestTemplateConfiguration {

    @Bean //  <bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
    @LoadBalanced //集成spring-cloud-loadbalancer组件。默认轮询
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
